<?php
include('init.php');
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
switch($act)
{
	case 'changpassword':
		$loginAccountID = SessionUtil::getVar(SESSION_KEY_LOGIN_ID);
		$db = AppMain::getDbDriver();
		$updateInfo = array(DBC_ACCOUNT_EMAIL=>$_REQUEST['email']);
		if(strlen($_REQUEST['password']) > 0)
		{
			$updateInfo[DBC_ACCOUNT_PASSWORD] = $_REQUEST['password'];
		}
		$db->updateSetWhere(DB_TABLE_NAME_ACCOUNT,$updateInfo, new SimpleWhereClause(DBC_ACCOUNT_ID, '=', $loginAccountID));
		$GLOBALS['successMessage'] = '修改成功';
		global_load_account_info_to_request();
	break;
}
?>
<?php include 'header.php' ?>
<?php include 'index_top.php' ?>

<script language="javascript">
function checkFormValue(form)
{
	if(form.password.value != '' && form.password.value != form.confirm.value)
	{
		alert('新密码和确认密码不同');
		return false;
	}
	form.submit();
	return false;
}
</script>
<form method="post">
<input type="hidden" name="act" value="changpassword"/>
<div class="adddiv">
<?php if(strlen($GLOBALS['successMessage']) > 0):?>
<div class="success_message">
	<?php echo $GLOBALS['successMessage'];?>
</div>
<?php endif;?>
<?php if(strlen($GLOBALS['errorMessage']) > 0):?>
<div class="error_message">
	<?php echo $GLOBALS['errorMessage'];?>
</div>
<?php endif;?>
	<label>邮箱</label>
	<input name="email" value="<?php echo $_REQUEST['CACHE_ACCOUNT_TABLE'][SessionUtil::getVar(SESSION_KEY_LOGIN_ID)][DBC_ACCOUNT_EMAIL];?>"/>
	<label>新密码</label>
	<input name="password" type="password"/>
	<label>确认密码</label>
	<input name="confirm" type="password"/>
	<label></label>
	<input type="button" value="OK" class="button" onclick="return checkFormValue(this.form);"/>
</div>
</form>
<?php include 'footer.php' ?>